/*
 *  ofxJSGlut.cpp
 *  liveCoding
 *
 *  Created by Julien Gachadoat on 20/09/09.
 *  Copyright 2009 2Roqs. All rights reserved.
 *
 */

#include "ofxJSGlut.h"
#include "js/ofxJSGlut.cpp"

//--------------------------------------------------------------
ofxJSGlut* ofxJSGlut::smp_instance = 0;

//--------------------------------------------------------------
ofxJSGlut::ofxJSGlut()
{
}

//--------------------------------------------------------------
ofxJSGlut::~ofxJSGlut()
{
}

//--------------------------------------------------------------
ofxJSGlut* ofxJSGlut::instance()
{
	return smp_instance;
}

//--------------------------------------------------------------
void ofxJSGlut::initialize()
{
	if (smp_instance == 0)
	{
		// Class definition
		ofxJSGlut::JSInit	(ofxJSGetContext(), ofxJSGetGlobalObj());

		// Create cpp instance
		smp_instance				= new ofxJSGlut();
		JSObject* jsInstance		= smp_instance->getJSObject(ofxJSGetContext());

		// Create gl instance
		if (JS_TRUE == JS_DefineProperty(ofxJSGetContext(), ofxJSGetGlobalObj(), "glut", OBJECT_TO_JSVAL(jsInstance), NULL, NULL, JSPROP_ENUMERATE))
			ofLog(OF_LOG_VERBOSE, "- defining 'glut' on globals object");
	}
}

//--------------------------------------------------------------
void ofxJSGlut::finalize()
{
	delete smp_instance;
}

//--------------------------------------------------------------
void ofxJSGlut::WireTeapot(float s){glutWireTeapot(s);}
void ofxJSGlut::WireSphere(float a,float b,float c){glutWireSphere(a,b,c);}
void ofxJSGlut::SolidSphere(float a,float b,float c){glutSolidSphere(a,b,c);}
void ofxJSGlut::WireIcosahedron(){glutWireIcosahedron();}
void ofxJSGlut::SolidIcosahedron(){glutSolidIcosahedron();}
void ofxJSGlut::WireDodecahedron(){glutWireDodecahedron();}
void ofxJSGlut::SolidDodecahedron(){glutSolidDodecahedron();}
void ofxJSGlut::WireCube(float s){glutWireCube(s);}
void ofxJSGlut::SolidCube(float s){glutSolidCube(s);}



